package com.ssy.lingxi.common.constant.basic;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 启用/停用，是/否状态枚举 1-启用 0-停用
 * @author 万宁
 * @version 2.0.0
 * @date 2020-06-15
 */
public enum EnableDisableStatus {

    /**
     * 启用、有效、是 - 1
     */
    ENABLE(1, "启用"),

    /**
     * 停用、无效、否 - 0
     */
    DISABLE(0, "停用");

    /**
     * 枚举值
     */
    private Integer code;

    EnableDisableStatus(Integer code, String name) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.getCode());
    }

    public static List<Integer> toList() {
        return Arrays.stream(EnableDisableStatus.values()).map(EnableDisableStatus::getCode).collect(Collectors.toList());
    }

    public static String getNameByCode(Integer code) {
        return LanguageHolder.getName(EnableDisableStatus.class, code);
    }
}
